/**
  ******************************************************************************
  * @file    sym32l010_hal_ram.h
  * @author  AE Team
  * @version 1.0.3
  * @date    2024-05-28
  * @brief   Header file of RAM HAL module.
  *
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2024 SIYIMicro.
  * All rights reserved.</center></h2>
  *
  *
  ******************************************************************************
  */


/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SYM32L010_HAL_RAM_H
#define __SYM32L010_HAL_RAM_H

#ifdef __cplusplus
extern "C" {
#endif


/******************************************************************************/
/* Include files                                                              */
/******************************************************************************/
#include "sym32l010_hal_def.h"


/******************************************************************************/
/* Global type definitions                                                    */
/******************************************************************************/


/******************************************************************************/
/* Global pre-processor symbols/macros ('#define')                            */
/******************************************************************************/
/* RAM 参数 ------------------------------------------------------------------*/
#define RAM_SIZE                           (*(volatile uint32_t *)(CHIPINFO_RAMSIZE_ADDR))
#define RAM_STARTADDR                      (0x20000000UL)
#define RAM_ENDADDR                        (RAM_STARTADDR + RAM_SIZE - 1)

/* IER -----------------------------------------------------------------------*/
#define RAM_IT_SOURCE_PARITY               (RAM_IER_PARITY_Msk)

/* ISR -----------------------------------------------------------------------*/
#define RAM_IT_FLAG_PARITY                 (RAM_ISR_PARITY_Msk)

/******************************************************************************/
/* Global macro function                                                      */
/******************************************************************************/
/**
  * @brief  获取 RAM 中断触发源
  * @param  ITSOURCE: RAM中断触发源
  *                   @arg RAM_IT_SOURCE_PARITY
  * @retval
  */
#define HAL_RAM_GET_IT_SOURCE(ITSOURCE)    (SYM_RAM->IER & (ITSOURCE))

/**
  * @brief  使能 RAM 中断触发源
  * @param  ITSOURCE: RAM中断触发源
  *                   @arg RAM_IT_SOURCE_PARITY
  * @retval
  */
#define HAL_RAM_ENABLE_IT(ITSOURCE)        (SYM_RAM->IER |= (ITSOURCE))

/**
  * @brief  关闭 RAM 中断触发源
  * @param  ITSOURCE: RAM中断触发源
  *                   @arg RAM_IT_SOURCE_PARITY
  * @retval
  */
#define HAL_RAM_DISABLE_IT(ITSOURCE)       (SYM_RAM->IER &= ~((uint32_t)(ITSOURCE)))

/**
  * @brief  获取 RAM 中断触发标志
  * @param  FLAG: RAM中断触发标志
  *               @arg RAM_IT_FLAG_PARITY
  * @retval
  */
#define HAL_RAM_GET_FLAG(FLAG)             (SYM_RAM->ISR & (FLAG))

/**
  * @brief  清除 RAM 中断触发标志
  * @param  FLAG: RAM中断触发标志
  *               @arg RAM_IT_FLAG_PARITY
  * @retval
  */
#define HAL_RAM_CLR_FLAG(FLAG)             (SYM_RAM->ICR = ~((uint32_t)(FLAG)))


/******************************************************************************/
/* Exported variables ('extern', definition in C source)                      */
/******************************************************************************/


/******************************************************************************/
/* Global function prototypes ('extern', definition in C source)              */
/******************************************************************************/
uint32_t HAL_RAM_GetParityErrorAddr(void);


#ifdef __cplusplus
}
#endif

#endif /* __SYM32L010_HAL_RAM_H */


/************************ (C) COPYRIGHT SIYIMicro *****END OF FILE*************/
